package org.gm.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

@Slf4j
@Component
public class FileLoaderHandler {
    public List<String> fileLoad(String fileName) {
        Scanner scanner = null;
        try {
            List<String> strings = new ArrayList<>();
            scanner = new Scanner(new File(fileName));
            while (scanner.hasNextLine()) {
                strings.add(scanner.nextLine());
            }
            return strings;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        } finally {
            if (scanner != null) {
                scanner.close();
            }
        }
    }
}
